<?php if(isset($_GET['doc'])){
  echo'docs';
  exit;
} ?>



var el=document.getElementById("<?php echo $_GET['el'] ?>"),
 p="<?php echo(isset($_GET['p'])?$_GET['p']:'') ?>",
  w=p.split(';'),wc=w.length,wi,wdef;

var pc=0,pdef=0,lc=0;
el.pics=new Array();
el.txts=new Array();
el.pic=0;

/*goh*/
el.width="640"
el.height="480";
/**/

for(wi=0;wi<wc;++wi){
    if(w[wi].substr(0,1)=='?'){
        el.txts[pc]=w[wi].substr(1);
    }
    else if(w[wi].substr(0,1)=='@'){ <?php include'_events.php' ?> }
    else if(w[wi].substr(0,1)=='!'){
      pdef=pc;
      el.pics[pc]=w[wi].substr(1);
      ++pc;
    }
    else if(w[wi].substr(0,1)=='$'){
    el.tag=w[wi].substr(1);
    }
    else if(w[wi].substr(0,1)=='_'){
    }
    else{
        el.pics[pc]=w[wi];
        ++pc;
    }
}


if(pdef!=el.pic)el.pic=pdef;
el.innerHTML="";
el.style.width=el.width+"px";
el.style.height=el.height+"px";
el.style.display="block";
el.style.overflow="hide;";
el.style.position="relative";
el.style.background="#fff";
el.style.textAlign="center";


el.img=document.createElement("img");
el.img.parent=el;
el.img.src=el.pics[el.pic];
el.img.style.width=el.width+"px";
el.img.style.height=el.height+"px";
el.img.style.zIndex="-9";
el.appendChild(el.img);
el.img.addEventListener("click",switchsize,false);
el.img.addEventListener("mouseout",pixout,false);
el.img.addEventListener("mouseover",pixover,false);


el.txt=document.createElement("div");
el.txt.style.position="absolute";
el.txt.style.bottom="0";
//el.txt.style.opacity="0";
//el.txt.style.zIndex="9";
el.appendChild(el.txt);

el.left=document.createElement("div");
el.left.parent=el;
//el.left.style.opacity="0";
el.left.style.position="absolute";
el.left.style.left="0";
el.left.style.top="0";
el.left.style.height="100%"
el.left.style.padding="0 1em";
el.left.style.background="#fff";
el.left.style.textAlign="right";
el.left.style.cursor="pointer";
el.left.innerHTML="&lt;<br/>&lt;";
el.appendChild(el.left);
el.left.addEventListener("mouseover",shownav,false);
el.left.addEventListener("mouseout",hidenav,false);
el.left.addEventListener("click",prevpix,false);

el.right=document.createElement("div");
el.right.parent=el;
//el.right.style.opacity="0";
el.right.style.position="absolute";
el.right.style.right="0";
el.right.style.top="0";
el.right.style.height="100%"
el.right.style.padding="0 1em";
//el.right.style.background="#fff";
el.right.style.textAlign="right";
el.right.style.cursor="pointer";
el.right.innerHTML="&gt;<br/>&gt;";
el.appendChild(el.right);
el.right.addEventListener("mouseover",shownav,false);
el.right.addEventListener("mouseout",hidenav,false);
el.right.addEventListener("click",nextpix,false);

pixset();

function switchsize(e){
    var t=e.target;
    if(t.parent.style.position=="relative"){
        t.parent.style.position="fixed";
        //alert(((window.innerWidth*0.5)-(t.naturalWidth*0.5)));
        //alert(window.width);
        t.parent.style.left=((window.innerWidth*0.5)-(t.naturalWidth*0.5))+"px";
        t.parent.style.top=((window.innerHeight*0.5)-(t.naturalHeight*0.5))+"px";;

        pixsize(t);
        t.style.width=t.naturalWidth+"px";
        t.style.height=t.naturalHeight+"px";
        t.parent.style.width=t.naturalWidth+"px";
        t.parent.style.height=t.naturalHeight+"px";

        t.parent.left.style.top=-Math.abs(t.naturalHeight)*0.5+"px";
        t.parent.left.style.height=-Math.abs(t.naturalHeight)*0.5+"px";
        t.parent.right.style.top=-Math.abs(t.naturalHeight)*0.5+"px";
        t.parent.txt.style.bottom=t.naturalHeight*1.5+"px";
        //  alert(t.parent.right.style.height);
    }
    else{
        t.parent.style.position="relative";
        t.parent.style.left="0";
        t.parent.style.top="0";
        t.style.width=t.parent.width+"px";
        t.style.height=t.parent.height+"px";
        t.parent.style.width=t.parent.width+"px";
        t.parent.style.height=t.parent.height+"px";
        t.parent.left.style.top="0";
        t.parent.right.style.top="0";
        t.parent.txt.style.top="0";
//alert(t.parent.style.position);
    }
}

function pixsize(el){
    el.style.width=el.naturalWidth+"px";
    el.style.height=el.naturalHeight+"px";
    el.parent.style.width=el.naturalWidth+"px";
    el.parent.style.height=el.naturalHeight+"px";
}

function pixover(e){
  e.target.parent.txt.style.opacity="1";
}
function pixout(e){
  e.target.parent.txt.style.opacity="0";
}

function shownav(e){
    e.target.style.opacity="1";
  //  pixover();
}

function hidenav(e){
    e.target.style.opacity="0";
    //pixout();
}

function prevpix(){
    if(el.pic>0)--el.pic;
    else el.pic=el.pics.length-1;
    pixset();

}

function nextpix(){
    if(el.pic<el.pics.length-1)++el.pic;
    else el.pic=0;
    pixset();
}

function pixset(){
    el.img.src=el.pics[el.pic];
    if(el.parent.style.position!="relative")pixsize(el.img);
    el.txt.innerHTML=el.txts[el.pic] || "";
}